﻿/*
#**************************************************************************
#  openSIS is a student information system for public and non-public 
#  schools from Open Solutions for Education, Inc. web: www.os4ed.com
#
#  openSIS is  web-based, open source, and comes packed with features that 
#  include student demographic info, scheduling, grade book, attendance, 
#  report cards, eligibility, transcripts, parent portal, 
#  student portal and more.   
#
#  Visit the openSIS web site at http://www.opensis.com to learn more.
#  If you have question regarding this system or the license, please send 
#  an email to info@os4ed.com.
#
#  This program is released under the terms of the GNU General Public License  
#  as  published by the Free Software Foundation, version 2 of the License. 
#  See license.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#**************************************************************************** 
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Web.UI.WebControls;
using OpenSIS.OpenSISWCFServiceReference;

/// <summary>
/// Summary description for Function
/// </summary>
/// 

namespace OSISFunction
{
    public class Function
    {
        public void ResetFormControlValues(Control parent)
        {
            foreach (Control c in parent.Controls)
            {
                if (c.Controls.Count > 0)
                {
                    ResetFormControlValues(c);
                }
                else
                {
                    switch (c.GetType().ToString())
                    {
                        case "System.Web.UI.WebControls.TextBox":
                            ((TextBox)c).Text = "";
                            break;

                            

                        case "System.Web.UI.WebControls.DropDownList":
                            if (c.ID == "ddlSchoolName" || c.ID == "ddlFullYear" || c.ID == "ddlLevel1")
                            {
                            }
                            else
                            {
                                ((DropDownList)c).SelectedIndex = -1;
                            }
                            break;
                        case "System.Web.UI.WebControls.CheckBox":
                            ((CheckBox)c).Checked = false;
                            break;
                        case "System.Web.UI.WebControls.RadioButton":
                            ((RadioButton)c).Checked = false;
                            break;



                    }
                }
            }

        }

        public void populateUserControls(ref DropDownList ddl)
        {
            OpenSISWCFServiceStudentSetupClient OSClient = new OpenSISWCFServiceStudentSetupClient();
            DataSet ds = null;
            ds = OSClient.populateUserControls();
            OSClient.Close();
            ddl.Items.Clear();
            ddl.DataSource = ds.Tables[0];
            ddl.DataTextField = "control_name";
            ddl.DataValueField = "control_id";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));  
        }

        public void populateCategory(ref DropDownList ddl, int SchoolID, string LangTool)
        {
            OpenSISWCFServiceStudentSetupClient OSClient2 = new OpenSISWCFServiceStudentSetupClient();
            DataSet ds = null;
            ds = OSClient2.populateCategory(SchoolID, LangTool);
            OSClient2.Close();
            ddl.Items.Clear();
            ddl.DataSource = ds.Tables[0];
            ddl.DataTextField = "Cat_Name";
            ddl.DataValueField = "Cat_Id";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));
            //ddl.Items.Insert(ddl.Items.Count, new ListItem("<< Add New >>", ""));
        }
    }
}